Skip to content

test: add test script for aznfs package#86

Merged
lixuemin2016 merged 1 commit intolinux-system-roles:mainfrom
lixuemin2016:testaznfs
Mar 3, 2026
Merged

test: add test script for aznfs package#86
lixuemin2016 merged 1 commit intolinux-system-roles:mainfrom
lixuemin2016:testaznfs

Conversation

@lixuemin2016
Copy link
Collaborator

@lixuemin2016 lixuemin2016 commented Feb 27, 2026

Enhancement:
Add a test script to validate Azure NFS Mount Helper (aznfs) installation and basic service.

This readiness validation is to ensure aznfs is properly installed and ready for use before performing real mount operations, mainly check below items:

  • aznfs package is installed
  • aznfswatchdog service is active
  • mount.aznfs command is available

Reason:
Add aznfs package test

Result:

`bash /opt/hpc/azure/tests/test-aznfs.sh
[2026-02-27 11:41:54] ========================================
[2026-02-27 11:41:54] Azure NFS Mount Helper (aznfs) Test
[2026-02-27 11:41:54] ========================================

[2026-02-27 11:41:54] Test: aznfs package installation...

Checking: aznfs package is installed
[PASS] aznfs package is installed

[2026-02-27 11:41:54] Test: aznfswatchdog status...

Checking: aznfswatchdog service is active
[PASS] aznfswatchdog service is active

[2026-02-27 11:41:54] Test: aznfs mount function...

Checking: mount.aznfs is available
[PASS] mount.aznfs is available
Checking: current aznfs mounts
[PASS] Found 1 active aznfs mount(s)

[2026-02-27 11:41:54] ========================================
[2026-02-27 11:41:54] All tests passed (4)`

Issue Tracker Tickets (Jira or BZ if any):
JIRA: RHELHPC-124

Summary by Sourcery

Tests:

  • Introduce a templated test-aznfs.sh script that verifies aznfs package installation, aznfswatchdog service status, and mount.aznfs availability, and install it into the Azure HPC tests directory.

@sourcery-ai
Copy link

sourcery-ai bot commented Feb 27, 2026

Reviewer's Guide

Adds an ansible-managed test script for the Azure NFS mount helper (aznfs) and installs it as an executable under the HPC Azure tests directory to validate aznfs package installation, watchdog service status, and basic mount readiness.

Sequence diagram for executing the aznfs test script

sequenceDiagram
    actor Admin
    participant TestScript as test_aznfs_sh
    participant PackageManager as rpm_or_dpkg
    participant Systemd as systemd
    participant Shell as shell

    Admin->>TestScript: Execute test_aznfs_sh
    TestScript->>TestScript: Print header and start tests

    TestScript->>PackageManager: Query aznfs package
    PackageManager-->>TestScript: Package status
    TestScript->>TestScript: Evaluate package installed
    TestScript->>Admin: Print PASS or FAIL for package

    TestScript->>Systemd: Check aznfswatchdog service status
    Systemd-->>TestScript: Service active/inactive
    TestScript->>TestScript: Evaluate service active
    TestScript->>Admin: Print PASS or FAIL for service

    TestScript->>Shell: Check mount_aznfs command availability
    Shell-->>TestScript: Command path or error
    TestScript->>TestScript: Evaluate command available
    TestScript->>Admin: Print PASS or FAIL for command

    TestScript->>Shell: List current aznfs mounts
    Shell-->>TestScript: Active aznfs mounts info
    TestScript->>TestScript: Count aznfs mounts
    TestScript->>Admin: Print PASS or FAIL for active mounts

    TestScript->>Admin: Print final summary and exit code
Loading

Flow diagram for the aznfs test script logic

flowchart TD
    A[Start test_aznfs_sh] --> B[Print test header]
    B --> C[Check aznfs package installed via package manager]
    C -->|installed| D[Print PASS for package]
    C -->|not installed| E[Print FAIL for package and set error flag]

    D --> F[Check aznfswatchdog service status via systemd]
    E --> F

    F -->|active| G[Print PASS for aznfswatchdog]
    F -->|inactive or missing| H[Print FAIL for aznfswatchdog and set error flag]

    G --> I[Check mount_aznfs command availability]
    H --> I

    I -->|available| J[Print PASS for mount_aznfs]
    I -->|not available| K[Print FAIL for mount_aznfs and set error flag]

    J --> L[List current aznfs mounts]
    K --> L

    L --> M[Count active aznfs mounts]
    M -->|count >= 0| N[Print PASS with mount count]

    N --> O{Any error flag set?}
    O -->|no| P[Print all tests passed and exit 0]
    O -->|yes| Q[Print failures detected and exit nonzero]
    P --> R[End]
    Q --> R[End]
Loading

File-Level Changes

Change Details Files
Install a new aznfs validation test script as part of the role tasks.
  • Add an Ansible template task after aznfs package installation to deploy test-aznfs.sh into the configured tests directory
  • Set ownership to root:root and make the script executable with mode 0755
tasks/main.yml
Introduce the aznfs test script template to verify installation, service status, and mount readiness.
  • Create a bash test harness that counts passed checks and exits on first failure
  • Implement checks for aznfs RPM installation, aznfswatchdog systemd service active state (and enabled state in verbose mode), and presence of mount.aznfs in PATH
  • Add a readiness check for current NFS mounts, with optional verbose listing, and structured timestamped logging plus -v/-h CLI options
templates/test-aznfs.sh.j2

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • The test_aznfs_mount check treats any mount entry with type nfs as an aznfs mount, which can misreport non-aznfs NFS mounts as aznfs; consider tightening the match (e.g., by checking the source, mount options, or helper in /proc/self/mountinfo) or explicitly clarifying that this is only a generic NFS sanity check.
  • The log messages like "Checking: aznfs package is installed or not" and "Checking: mount.aznfs command is available or not" could be simplified for readability (e.g., "Checking: aznfs package is installed") to keep test output concise and consistent.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The `test_aznfs_mount` check treats any `mount` entry with `type nfs` as an aznfs mount, which can misreport non-aznfs NFS mounts as aznfs; consider tightening the match (e.g., by checking the source, mount options, or helper in `/proc/self/mountinfo`) or explicitly clarifying that this is only a generic NFS sanity check.
- The log messages like "Checking: aznfs package is installed or not" and "Checking: mount.aznfs command is available or not" could be simplified for readability (e.g., "Checking: aznfs package is installed") to keep test output concise and consistent.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

until: __hpc_azure_packages_install is success


- name: Install package aznfs test script
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do users need it? Or it's only for our internal tests?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@spetrosi thank you so much for review.

Based on my understanding, similar to test-moneo.sh.j2 and test-azure-health-checks.sh.j2, this new test script test-aznfs.sh.j2 might be useful for both users and our internal testing processes.

The question is whether to include an option to enable these test installations in future or simply add these test scripts to simplify the process as current method. As we know, other older packages do not have their specific tests integrated as Ansible scripts yet.

For newly added packages, we have two separate testing tasks:

  1. Testing package: defining how to test the package, typically by adding the test within an Ansible script.
  2. Automation: developing the automated test case within the end-to-end (e2e) test repository.

Hi @dgchinner,

Could you please help to check whether I understand the questions about "Do users need it? Or it's only for our internal tests?" correctly? Do we need a overall ansible parameter to control whether need to install test script?

Thank you so much.
Xuemin

Add a test script to validate Azure NFS Mount Helper (aznfs)
installation and basic service.

This readiness validation is to ensure aznfs is properly installed
and ready for use before performing real mount operations, mainly
check below items:

- aznfs package is installed
- aznfswatchdog service is active
- mount.aznfs command is available

JIRA: RHELHPC-124

Signed-off-by: Xuemin Li <xuli@redhat.com>
@lixuemin2016 lixuemin2016 merged commit f84e7c8 into linux-system-roles:main Mar 3, 2026
21 of 22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants